package com.ddxz.demo.shiro.service.impl;

import com.ddxz.demo.shiro.dto.LoginInfo;
import com.ddxz.demo.shiro.service.ShiroService;
import com.ddxz.tool.web.dto.DdxzResponse;
import org.apache.shiro.SecurityUtils;
import org.apache.shiro.authc.UsernamePasswordToken;
import org.apache.shiro.subject.Subject;
import org.springframework.stereotype.Service;

/**
 * class description
 *
 * @author 朱宗刚
 * @version 1.0.0
 * @date 2020/11/25
 */

@Service
public class ShiroServiceImpl implements ShiroService {
    @Override
    public DdxzResponse login(LoginInfo info) {
        UsernamePasswordToken token = new UsernamePasswordToken(info.getUsername(), info.getPassword());
        Subject subject = SecurityUtils.getSubject();
        subject.login(token);
        return DdxzResponse.correct("登陆成功");
    }

    @Override
    public DdxzResponse getUserInfo(String userId) {
        return DdxzResponse.correct("获取用户详情成功");
    }

    @Override
    public DdxzResponse getDeptInfo(String deptId) {
        return DdxzResponse.correct("获取部门详情成功");
    }
}
